var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", { value: !0 });
var a = t("UIConfig"),
    i = t("UIManager"),
    n = t("SdkManager"),
    r = t("GameCof"),
    s = t("AdView"),
    c = new((function() {
        function t() {
            this.timeCount = 0;
            this.lastLoginTime = "";
            this.sendId = {
                30: "3001",
                60: "3002",
                120: "3003",
                180: "3004",
                240: "3005",
                300: "3006",
                500: "3007",
                600: "3008",
                1200: "3009",
                1800: "3010",
                3600: "3011"
            };
            this.startEnterGame = !1;
            this.firstEnterGameEv = !1;
            this.loginCount = 10;
            this.privacyIsOver = !1;
        }
        t.prototype.sendRemberTime = function() {
            // if ("" != r.default.UID) {
            //     var t = this.timeCount;
            //     this.timeCount = 0;
            //     var e = {
            //             uid: r.default.UID,
            //             logintime: this.lastLoginTime,
            //             duration: t,
            //             gameid: r.default.gameid,
            //             channel: r.default.channel,
            //             sendtime: Date.now()
            //         },
            //         o = r.default.baseUrl + r.default.baseLibPathV2 + r.default.pathDurationSubmit;
            //     this.requestJson(o, function() {}, this, "POST", null, e, "application/json");
            // }
        };
        t.prototype.updateAddTime = function() {
            r.default.isInitAccount &&
                AdView.showAd(function() {
                    console.log("来自闲置");
                }, s.AdTypeEm.idle);
            this.timeCount++;
            this.timeCount % 30 == 0 && this.sendRemberTime();
            this.sendId[this.timeCount] && QReport.sendOnce(this.sendId[this.timeCount]);
        };
        t.prototype.sendLogin = function() {
            cc.sys.platform == cc.sys.ANDROID ?
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/MyApplication", "initDelayCheck", "()V") :
                QReport.pointLog("发送登录 ");
        };
        t.prototype.getDevId = function() {
            if ("vivo" == r.default.curPlat) {
                if ("undefined" != typeof AdView.Plat) {
                    var t = AdView.Plat.getSystemInfoSync();
                    AdView.devId = t.model + "_" + t.product;
                }
            } else if ("oppo" == r.default.curPlat) {
                if ("undefined" != typeof AdView.Plat) {
                    t = AdView.Plat.getSystemInfoSync();
                    AdView.devId = t.model;
                }
            } else if ("tt" == r.default.curPlat) {
                if ("undefined" != typeof AdView.Plat) {
                    t = AdView.Plat.getSystemInfoSync();
                    AdView.devId = t.brand + "_" + t.model;
                }
            } else
                cc.sys.platform == cc.sys.ANDROID ?
                "" == AdView.devId &&
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/MyApplication", "getDevId", "()V") :
                QReport.pointLog("发送登录 ");
        };
        t.prototype.checkEnterZhuce = function() {
            this.sendZhuCe();
        };
        t.prototype.checkLogin = function(t, e, o, a) {
            this.getDevId();
            if (AdView.devId) this.doLogining(t, e, o, a);
            else {
                this.doLogining(t, e, o, a);
                this.checkSendDev(t, e, o);
            }
        };
        t.prototype.checkSendDev = function(t, e, o) {
            var a = this;
            if (this.loginCount > 0) {
                this.loginCount--;
                AdView.devId ?
                    this.doLogining(t, e, o, null) :
                    setTimeout(function() {
                        a.checkSendDev(t, e, o);
                    }, 500);
            }
        };
        t.prototype.doLogining = function(t, e, o, a) {
            var i = this;
            console.log("GameBaseManager ----------------- 登录账号:" + e);
            var s = "" + e,
                c = "" + e,
                p = r.default.platname,
                l = r.default.version,
                d = r.default.baseUrlV3;
            if (r.default.isMiniGame) n.default.login();
            else {
                var u =
                    d +
                    r.default.baseLibPathV3 +
                    r.default.pathPlatformLogin2 +
                    "?account=" +
                    s +
                    "&password=" +
                    c +
                    "&platform=" +
                    p +
                    "&version=" +
                    l +
                    "&devid=" +
                    AdView.devId +
                    "&type=2&channel=" +
                    r.default.channel +
                    "&instime=" +
                    r.default.gamecacheLoginType1Count +
                    "&isclouds=" +
                    r.default.isCloud;
                "" != r.default.token ?
                    a && a(o, r.default.token) :

                    cc.resources.load("login", (err, t) => {
                        // this.requestJson(
                        // u,
                        // function(t) {
                        t = t.json;
                        console.log("GameBaseManager ------------ssss----- 登录结果", u + "\n", t);
                        if (1 == t.code) {
                            var e = t.data;
                            e.lastlogintime = Date.now();
                            r.default.setLastLoginTime(e.lastlogintime);
                            var n,
                                s = e.token;
                            r.default.setToken(s);
                            i.lastLoginTime = e.lastlogintime;
                            r.default.UID = e.uid;
                            a && a(o, r.default.token);
                            e.fcm;
                            n = t.data.storageVer || 0;
                            if (1 == t.registerCode);
                            else if (2 == t.registerCode) {
                                var c = t.data.storageAry;
                                if (c && c.length <= 0);
                                else {
                                    var p = {};
                                    if (n >= r.default.getLoginDataVersion())
                                        for (var l = 0; l < c.length; l++) {
                                            var d = c[l],
                                                h = d.StorageKey,
                                                f = d.contents;
                                            d.deadline, d.encryptStr;
                                            p[h] = f;
                                        }
                                    r.default.addCloudCache(p);
                                }
                            }
                            r.default.setLoginVersion(n + 1);
                        }
                    });
            }
        };
        t.prototype.sendAndroidInit = function() {
            console.log("GameBaseManager ----------------- stalk  开始注册 平台判断", cc.sys.platform, cc.sys.ANDROID);
            if (cc.sys.platform == cc.sys.ANDROID) {
                console.log("GameBaseManager ----------------- stalk  开始注册 sdk");
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/MyApplication", "initSdk", "()V");
            } else QReport.pointLog("初始sdk");
        };
        t.prototype.checkViewFanChenmi = function() {
            var t = this,
                // e = r.default.canEnterPath;
                e = { "a1": 0 };
            // this.requestJson(
            //     e,
            //     function(e) {
            console.log("Login ----------------- 权限数据", e);
            var o = r.default.getLastId();
            if (e && 1 == e.a1 && "1" != r.default.getFCM()) i.default.open(a.UIID.UIFangCheng);
            else {
                t.sendFirstEnterGame();
                t.startEnterGame = !0;
            }
            t.checkLogin("", o, "", function() {});
            //     },
            //     this
            // );
        };
        t.prototype.sendZhuCe = function() {
            var t = this;
            if (cc.sys.platform == cc.sys.ANDROID) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/MyApplication", "shiming", "()V");
                setTimeout(function() {
                    t.sendLogin();
                }, 200);
            } else QReport.pointLog("服务器 登录完成 发送 头条注册完成 ");
        };
        t.prototype.sendFirstEnterGame = function() {
            this.firstEnterGameEv || (this.firstEnterGameEv = !0);
        };
        t.prototype.getShareRewardTimes = function() {
            var t = GameDataValue.getPropCount("shareTimes"),
                e = GameDataValue.getPropCount("lastShareTime"),
                o = new Date(e),
                a = new Date(Date.now());
            o.setHours(0, 0, 0, 0) != a.setHours(0, 0, 0, 0) && (t = 0);
            return t;
        };
        t.prototype.requestJson = function(t, e, o, a, i, n, r) {
            void 0 === a && (a = "GET");
            void 0 === i && (i = null);
            void 0 === n && (n = null);
            void 0 === r && (r = "application/x-www-form-urlencoded");
            var s = new XMLHttpRequest();
            s.onreadystatechange = function() {
                if (4 == s.readyState)
                    if (s.status >= 200 && s.status < 400) e && e.call(o, JSON.parse(s.responseText));
                    else {
                        console.log("XMLHttpRequest error:", t, s.status, s.responseText);
                        i && i.call(o, s);
                    }
            };
            s.open(a, t, !0);
            s.setRequestHeader("Content-type", r);
            null == n ? s.send() : s.send(JSON.stringify(n));
        };
        return t;
    })())();
window.GameBaseManager = c;
o.default = c;